export function watchMouseDown(
  {
    target,
    onDown,
    onUp
  }: {
    target?: HTMLElement | null;
    onDown: () => any;
    onUp: () => any;
  }
) {
  if (target) {
    let isDown = false
    document.addEventListener('mouseup', (e: MouseEvent) => {
      if (isDown) onUp();
    })
    console.log(target);
    target.addEventListener('mousedown', (e: MouseEvent) => {
      onDown()
      isDown = true
    })
  }
}